package com.cloud.shuiyu.controller;

import com.cloud.shuiyu.service.PaymentService;
import com.shuiyu.cloud.entities.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author rjw
 * <p>Description:   </p>
 * @ClassName PaymentController
 * @time 2021/7/17 10:31
 */
@RestController
@Slf4j
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/payment/hystrix/OK/{id}")
    public String payment_OK(@PathVariable("id") Integer id){
        String s = paymentService.paymentinfo_OK(id);
        log.info("*****result"+s);
        return s;
    }

    @GetMapping("/payment/hystrix/TimeOut/{id}")
    public String payment_TimeOut(@PathVariable("id") Integer id){
        String s = paymentService.paymentinfo_TimeOut(id);
        log.info("*****result"+s);
        return s;
    }

    //=======服务熔断
    @GetMapping("/payment/circuit/{id}")
    public  String paymentCircuitBreaker(@PathVariable("id") Integer id){
        String s = paymentService.paymentCircuitBreaker(id);
        log.info("===========s："+s);
        return s;
    }
}
